// 日期区间
var endtime= laydate.render({
  elem: '#end_time'
  
});
laydate.render({
  elem: '#start_time'
 ,done: function(value, date, endDate){
    console.log(value); //得到日期生成的值，如：2017-08-18
   
    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
    console.log(endtime)
    date.month=(date.month-1)
     console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
	endtime.config.min=date
  }
});

Load()
var data={};
{if $Think.get.start_time}
data.start_time=$('#start_time').val();
{/if}
{if $Think.get.end_time}
data.end_time=$('#end_time').val();
{/if}
ajax(api.order.stat, data, 'post').done((res) => {
	Load(1)
	console.log(res)
	//总订单数
	var allorder = echarts.init(document.getElementById('allorder'));
	option = {
		title: false,
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c} ({d}%)"
		},
		legend: {
			orient: 'vertical',
			left: 'left',
			data: ['行政执法', '特殊公务', '重要会议', '机要通讯', '视察调研', '公务接待', '应急公务', '紧急就医']
		},
		series: [{
			name: '订单数量',
			type: 'pie',
			radius: '55%',
			center: ['50%', '60%'],
			data: [{
					value: res.data.order_number[1],
					name: '行政执法'
				},
				{
					value: res.data.order_number[2],
					name: '特殊公务'
				},
				{
					value: res.data.order_number[3],
					name: '重要会议'
				},
				{
					value: res.data.order_number[4],
					name: '机要通讯'
				},
				{
					value: res.data.order_number[5],
					name: '视察调研'
				},
				{
					value: res.data.order_number[6],
					name: '公务接待'
				},
				{
					value: res.data.order_number[7],
					name: '应急公务'
				},
				{
					value: res.data.order_number[8],
					name: '紧急就医'
				}
			],
			itemStyle: {
				emphasis: {
					shadowBlur: 10,
					shadowOffsetX: 0,
					shadowColor: 'rgba(0, 0, 0, 0.5)'
				}
			}
		}]
	};
	// 使用刚指定的配置项和数据显示图表。
	allorder.setOption(option);
	// 订单总数列表
	var data = [{
			order_type: '行政执法',
			order_number: res.data.order_number[1],
			percentage: res.data.order_number_percent[1]+'%'
		},
		{
			order_type: '特殊公务',
			order_number: res.data.order_number[2],
			percentage: res.data.order_number_percent[2]+'%'
		},
		{
			order_type: '重要会议',
			order_number: res.data.order_number[3],
			percentage: res.data.order_number_percent[3]+'%'
		},
		{
			order_type: '机要通讯',
			order_number: res.data.order_number[4],
			percentage: res.data.order_number_percent[4]+'%'
		},
		{
			order_type: '视察调研',
			order_number: res.data.order_number[5],
			percentage: res.data.order_number_percent[5]+'%'
		},
		{
			order_type: '公务接待',
			order_number: res.data.order_number[6],
			percentage: res.data.order_number_percent[6]+'%'
		},
		{
			order_type: '应急公务',
			order_number: res.data.order_number[7],
			percentage: res.data.order_number_percent[7]+'%'
		},
		{
			order_type: '紧急就医',
			order_number: res.data.order_number[8],
			percentage: res.data.order_number_percent[8]+'%'
		},
	]
	table.render({
		elem: '#allorder2',
		data: data,
		cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
			,
		cols: [
			[{
				field: 'order_type',
				title: '订单类别'
			}, {
				field: 'order_number',
				title: '订单数'
			}, {
				field: 'percentage',
				title: '占比'
			}]
		]
	});

	//总订单金额
	element.on('tab(demo)', function(data) {
		console.log(data.index)
		if(data.index == 1) {
			var allmoney = echarts.init(document.getElementById('allmoney'));
			option1 = {
				title: false,
				tooltip: {
					trigger: 'item',
					formatter: "{a} <br/>{b} : {c} ({d}%)"
				},
				legend: {
					orient: 'vertical',
					left: 'left',
					data: ['行政执法', '特殊公务', '重要会议', '机要通讯', '视察调研', '公务接待', '应急公务', '紧急就医']
				},
				series: [{
					name: '订单数量',
					type: 'pie',
					radius: '55%',
					center: ['50%', '60%'],
					data: [{
							value: res.data.order_money[1],
							name: '行政执法'
						},
						{
							value: res.data.order_money[2],
							name: '特殊公务'
						},
						{
							value: res.data.order_money[3],
							name: '重要会议'
						},
						{
							value: res.data.order_money[4],
							name: '机要通讯'
						},
						{
							value: res.data.order_money[5],
							name: '视察调研'
						},
						{
							value: res.data.order_money[6],
							name: '公务接待'
						},
						{
							value: res.data.order_money[7],
							name: '应急公务'
						},
						{
							value: res.data.order_money[8],
							name: '紧急就医'
						}
					],
					itemStyle: {
						emphasis: {
							shadowBlur: 10,
							shadowOffsetX: 0,
							shadowColor: 'rgba(0, 0, 0, 0.5)'
						}
					}
				}]
			};
			allmoney.setOption(option1);
			var data = [{
					order_type: '行政执法',
					order_number: res.data.order_money[1],
					percentage: res.data.order_money_percent[1]+'%'
				},
				{
					order_type: '特殊公务',
					order_number: res.data.order_money[2],
					percentage: res.data.order_money_percent[2]+'%'
				},
				{
					order_type: '重要会议',
					order_number: res.data.order_money[3],
					percentage: res.data.order_money_percent[3]+'%'
				},
				{
					order_type: '机要通讯',
					order_number: res.data.order_money[4],
					percentage: res.data.order_money_percent[4]+'%'
				},
				{
					order_type: '视察调研',
					order_number: res.data.order_money[5],
					percentage: res.data.order_money_percent[5]+'%'
				},
				{
					order_type: '公务接待',
					order_number: res.data.order_money[6],
					percentage: res.data.order_money_percent[6]+'%'
				},
				{
					order_type: '应急公务',
					order_number: res.data.order_money[7],
					percentage: res.data.order_money_percent[7]+'%'
				},
				{
					order_type: '紧急就医',
					order_number: res.data.order_money[8],
					percentage: res.data.order_money_percent[8]+'%'
				},
			]
			table.render({
				elem: '#allmoney2',
				data: data,
				cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
					,
				cols: [
					[{
						field: 'order_type',
						title: '订单类别'
					}, {
						field: 'order_number',
						title: '订单金额'
					}, {
						field: 'percentage',
						title: '占比'
					}]
				]
			});
		} else if(data.index == 2) {
			var data = [{
					order_type: '行政执法',
					order_number: res.data.order_time[1],
					percentage: res.data.order_time_percent[1]+'%'
				},
				{
					order_type: '特殊公务',
					order_number: res.data.order_time[2],
					percentage: res.data.order_time_percent[2]+'%'
				},
				{
					order_type: '重要会议',
					order_number: res.data.order_time[3],
					percentage: res.data.order_time_percent[3]+'%'
				},
				{
					order_type: '机要通讯',
					order_number: res.data.order_time[4],
					percentage: res.data.order_time_percent[4]+'%'
				},
				{
					order_type: '视察调研',
					order_number: res.data.order_time[5],
					percentage: res.data.order_time_percent[5]+'%'
				},
				{
					order_type: '公务接待',
					order_number: res.data.order_time[6],
					percentage: res.data.order_time_percent[6]+'%'
				},
				{
					order_type: '应急公务',
					order_number: res.data.order_time[7],
					percentage: res.data.order_time_percent[7]+'%'
				},
				{
					order_type: '紧急就医',
					order_number: res.data.order_time[8],
					percentage: res.data.order_time_percent[8]+'%'
				},
			];
			table.render({
				elem: '#alltime2',
				data: data,
				cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
					,
				cols: [
					[{
						field: 'order_type',
						title: '订单类别'
					}, {
						field: 'order_number',
						title: '订单耗时'
					}, {
						field: 'percentage',
						title: '占比'
					}]
				]
			});
			var alltime = echarts.init(document.getElementById('alltime'));
			option2 = {
				title: false,
				tooltip: {
					trigger: 'item',
					formatter: "{a} <br/>{b} : {c} ({d}%)"
				},
				legend: {
					orient: 'vertical',
					left: 'left',
					data: ['行政执法', '特殊公务', '重要会议', '机要通讯', '视察调研', '公务接待', '应急公务', '紧急就医']
				},
				series: [{
					name: '订单数量',
					type: 'pie',
					radius: '55%',
					center: ['50%', '60%'],
					data: [{
							value: res.data.order_time[1],
							name: '行政执法'
						},
						{
							value: res.data.order_time[2],
							name: '特殊公务'
						},
						{
							value: res.data.order_time[3],
							name: '重要会议'
						},
						{
							value: res.data.order_time[4],
							name: '机要通讯'
						},
						{
							value: res.data.order_time[5],
							name: '视察调研'
						},
						{
							value: res.data.order_time[6],
							name: '公务接待'
						},
						{
							value: res.data.order_time[7],
							name: '应急公务'
						},
						{
							value: res.data.order_time[8],
							name: '紧急就医'
						}
					],
					itemStyle: {
						emphasis: {
							shadowBlur: 10,
							shadowOffsetX: 0,
							shadowColor: 'rgba(0, 0, 0, 0.5)'
						}
					}
				}]
			};
			alltime.setOption(option2);
		}
	});
	//总订单耗时	

}).fail(() => {})

